void hsv2rgb(int* hsv, byte* rgb){
  float h = hsv[0];  
  float s = hsv[1] / 100.0;
  float v = hsv[2] / 100.0;
  
  if (h >= 360) h = 0;
  
  int hi = (int)(h / 60.0) % 6;
  float f = (h / 60.0) - (float)hi;
  float l = v * ( 1.0 - s);
  float m = v * ( 1.0 - f * s);
  float n = v * (1.0 - s * (1.0 - f) );
  
  float r, g, b;
  switch(hi){
    case 0:      
      r=v ; g=n ; b=l ; 
    break;
    case 1:
      r=m ; g=v ; b=l ; 
    break;
    case 2:
      r=l ; g=v ; b=n ; 
    break;
    case 3:
      r=l ; g=m ; b=v ; 
    break;
    case 4:
      r=n ; g=l ; b=v ; 
    break;
    case 5:
      r=v ; g=l ; b=m ; 
    break;    
  }
  
  rgb[0] = r * 255;
  rgb[1] = g * 255;
  rgb[2] = b * 255;
  
  
  //TO REMOVE IF USING A RESISTOR BEFORE THE LED
  /*rgb[0] = min(rgb[0],1);
 rgb[1] = min(rgb[1],1);
 rgb[2] = min(rgb[2],1);*/
 
 
}

void printColor_b(byte* color){
  Serial.print("RGB ");
  Serial.print(color[0], DEC);
  Serial.print(":");
  Serial.print(color[1], DEC);
  Serial.print(":");
  Serial.print(color[2], DEC);  
  Serial.println(";");
}

void printColor_i(int* color){
  Serial.print("HSV ");
  Serial.print(color[0], DEC);
  Serial.print(":");
  Serial.print(color[1], DEC);
  Serial.print(":");
  Serial.print(color[2], DEC);  
  Serial.println(";");
}

